package service.impl;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;
import org.springframework.web.context.ContextLoader;
import service.Service1;
import service.Service2;

/**
 * author: liweiwei
 * Date: 2018/12/7
 */
@Service
public class Service1Impl implements Service1,ApplicationContextAware {


    private ApplicationContext applicationContext;

    public Service1Impl() {
        System.out.println("_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+_+");
    }

    @Autowired
    private Service2 service2;
    @Override
    public void printApplicationName() {

        System.out.println(applicationContext.getApplicationName()+":"+applicationContext.getDisplayName());
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext=applicationContext;
    }
}
